package com.sgb.kjwl.view.widget;

import android.content.Context;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.user.SingleEntity;
import com.sgb.kjwl.view.ui.adapter.self.SingleAdapter;
import com.swgk.core.dialog.BasePopWindow;
import com.swgk.core.dialog.PopViewHolder;
import com.swgk.core.recyclerview.adapter.AdapterOnItemClick;
import com.swgk.core.recyclerview.decoration.RecyclerCustomDecoration;

import java.util.List;

public class SinglePopWindow extends BasePopWindow {
    private RecyclerView recyclerView;
    private SingleAdapter singleAdapter;
    private List<SingleEntity> singleEntityList;

    public SinglePopWindow(Context context) {
        super(context);
    }

    @Override
    protected int popLayout() {
        return R.layout.popwindow_single;
    }

    @Override
    protected void initView(PopViewHolder holder) {
        recyclerView = holder.getPop().findViewById(R.id.rlv_list);
        singleAdapter = new SingleAdapter(mContext, null);
        singleAdapter.setItemSelect(true);
        recyclerView.setLayoutManager(new GridLayoutManager(mContext, 1));
        recyclerView.addItemDecoration(new RecyclerCustomDecoration(0,
                0,
                0,
                mContext.getResources().getDimension(R.dimen.dp1), mContext.getResources().getColor(R.color.color_F5F5F5)));
        recyclerView.setAdapter(singleAdapter);
        singleAdapter.setOnItemClick(new AdapterOnItemClick<SingleEntity>() {
            @Override
            public void onItemClick(SingleEntity singleEntity, int position) {
                dissMiss();
            }
        });
    }

    public void setData(List<SingleEntity> singleEntityList) {
        this.singleEntityList = singleEntityList;
        singleAdapter.setDatas(singleEntityList);
    }
}
